<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%String path=request.getContextPath();pageContext.setAttribute("path",path); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
	<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
	<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
	
<title>查看回答</title>
</head>

<body>
	<div data-role="page" id="details">
    <div data-theme="a" data-role="header">
        <h3>
            查看回答
        </h3>
       
    </div>
    <div data-role="content">
            
            <div data-role="fieldcontain">
                <input name="subject"   value="${question.subject}" type="text" readonly="readonly">
            </div>
            <div data-role="fieldcontain">
                <textarea name="content"   readonly="readonly">${question.content}</textarea>
            </div>
            
            <c:forEach items="${question.answers}" var="answer">
            <div style=" text-align:right">
	            <a href="">
            	<img style="width: 40px; height: 40px;cursor: pointer;" src="${answer.expert.icon}" >
    		    </a>
        	</div>
        	
        	<div style=" ">
        		<label for="a_${answer.aid}">专家 ${answer.expert.name} 的 解答</label>
        		<textarea name="content" id="a_${answer.aid}"  readonly="readonly">${question.content}</textarea>
        	</div>
        	
        	<c:if test="${answer.score == null }">
	        	<a href="${path}/answer/scoreView.do?id=${answer.aid}" role="button" class="ui-shadow ui-btn ui-corner-all "  data-transition="flip">我要评分</a>
        	</c:if>
        	
            </c:forEach>

        	<c:if test="${question.answers[0].score !=null && question.status>0}">
	       		 <a href="#popupDialog" data-rel="popup" data-position-to="window" data-transition="pop" data-role="button" >对答案不满意再次提交问题</a>
				<div data-role="popup" id="popupDialog" data-overlay-theme="a" data-theme="a" data-dismissible="false" style="max-width:400px;">
				    <div data-role="header" data-theme="a">
				    <h1>提示</h1>
				    </div>
				    <div role="main" class="ui-content">
				        <h3 class="ui-title">您确定对答案不满意再次提交问题?</h3>
				    	<p>点击后将不能取消.</p>
				        <a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-a" data-rel="back">取消</a>
				        <a href="" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-a" data-rel="back" data-transition="flow" id="reSubmit_${question.qid}">提交问题</a>
				    </div>
				</div>
        	</c:if>
	        
			
			<script type="text/javascript">
					$("#reSubmit_${question.qid}").click(function () {
						var result=false;
						var data={ id:"${question.qid}" };
						$.ajax({type:"POST",url:"${path}/question/reSubmit.do",data:data,async:false,dataType:"json",success:function(r){
							result=r.success;
							if(result){
								alert("提交成功!");
								$.mobile.changePage("${path}/question/details.do?id=${question.qid}&_t=<%=System.currentTimeMillis()%>");
							}else{
								alert("提交失败!");
							}
						}});
						return false;
					});
			</script>
    </div>
   <jsp:include page="foot.jsp"/>
</div>

</body>
</html>
